import sys

class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        sign = 1 if x>=0 else -1
        x = abs(x)
        s = list(str(x))
        s.reverse()
        ret = int("".join(s))
        if ret>=2**31: return 0
        else: return ret * sign

print(Solution().reverse(1))